#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdlib.h>
int main()
{
  pid_t id=fork();
  if(id==0)
  {
    //child
    sleep(3);
    printf("i am process...\n");
    //execl("/usr/bin/ls","ls","-a","-l",NULL);//以绝对路径替换
    // execlp("ls","ls","-a","-l",NULL);//以文件名替换
   // char*argv[]={"ls","-a","-l","-i",NULL};
    //char*envp[]={"MYENV=haha",NULL};
    //execv("/usr/bin/ls",argv);//以绝对路径，以数组形式进行执行命令
   // execle("/usr/bin/ls","ls","-l","-a",NULL,envp);//自己维护环境变量
  //execve("/usr/bin/ls",argv,envp);
    //execl("./test","test",NULL);
   execlp("./test","test",NULL);//调用外部程序
    exit(10);
  }
 // else if(id>0)//father
  int status=0;
  pid_t ret=waitpid(id,&status,0);
  if(ret>0)
  {
    printf("exit signal:%d\n",WIFEXITED(status));
    printf("exit code:%d\n",WEXITSTATUS(status));
  }
  return 0;
}
